/*
 * Copyright 2016 Wealth Inc. All rights reserved.
 */
 package com.wealth.bank.repository;

import java.util.List;

import iaas.repository.BaseRepository;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.wealth.bank.entity.Article;

/**
 * @author chan
 * @version 1.0
 * @since 1.0
 */
 
@Repository
public interface ArticleDao extends BaseRepository<Article, Long> ,JpaSpecificationExecutor<Article>{

	/**
	 * 查询银行文章
	 * @param status
	 * @return
	 */
	@Query(value="SELECT * FROM bank_article WHERE id>?1 AND STATUS =?2 AND corp_id=?3 ORDER BY create_time LIMIT 20",nativeQuery=true)
	public List<Article> getArticlePag(Integer id,Integer status,Long corpId);
	
	/**
	 * 查询某分类下文章列表
	 * @param categoryId
	 * @param status
	 * @return
	 */
	@Query(value="SELECT * FROM bank_article WHERE id>?1 AND STATUS =?2 AND category_id =?3 AND corp_id=?4 ORDER BY id  LIMIT 10",nativeQuery=true)
	public List<Article> getArticlePagByCategoryId(Integer id,Integer status,Long category_id,Long corpId);
	
	/**
	 * 查询某分类下文章列表(加载更多)
	 * @param categoryId
	 * @param status
	 * @return
	 */
	@Query(value="SELECT * FROM bank_article WHERE id>?1 AND STATUS =?2 AND category_id =?3 AND corp_id=?4 ORDER BY id LIMIT 10",nativeQuery=true)
	public List<Article> getArticlePagByCategoryIdMove(Integer id,Integer status,Long category_id,Long corpId);
	
}
